<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
     function foo(func){
         for(var  i=0,length = this.length;i<length;i++){
             /* 函数接收一个函数类型的参数，不仅可以调用这个参数，还可以为这个函数类型的参数添加参数 */
             func(i,this[i],this);
         }
     }

     Array.prototype.foo = foo;


     var arr =[6,4,1,2,7];
     arr.foo(function(index,cur,arr){
         console.log(index);
         console.log(cur);
         console.log(arr);
     })



        
    </script>
</body>
</html>